package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Exappointment;
import com.ruoyi.system.service.IExappointmentService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 展览预约Controller
 * 
 * @author ruoyi
 * @date 2024-01-18
 */
@Controller
@RequestMapping("/system/exappointment")
public class ExappointmentController extends BaseController
{
    private String prefix = "system/exappointment";

    @Autowired
    private IExappointmentService exappointmentService;

    @RequiresPermissions("system:exappointment:view")
    @GetMapping()
    public String exappointment()
    {
        return prefix + "/exappointment";
    }

    /**
     * 查询展览预约列表
     */
    @RequiresPermissions("system:exappointment:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(Exappointment exappointment)
    {
        startPage();
        List<Exappointment> list = exappointmentService.selectExappointmentList(exappointment);
        return getDataTable(list);
    }

    /**
     * 导出展览预约列表
     */
    @RequiresPermissions("system:exappointment:export")
    @Log(title = "展览预约", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(Exappointment exappointment)
    {
        List<Exappointment> list = exappointmentService.selectExappointmentList(exappointment);
        ExcelUtil<Exappointment> util = new ExcelUtil<Exappointment>(Exappointment.class);
        return util.exportExcel(list, "展览预约数据");
    }

    /**
     * 新增展览预约
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存展览预约
     */
    @RequiresPermissions("system:exappointment:add")
    @Log(title = "展览预约", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(Exappointment exappointment)
    {
        return toAjax(exappointmentService.insertExappointment(exappointment));
    }

    /**
     * 修改展览预约
     */
    @RequiresPermissions("system:exappointment:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        Exappointment exappointment = exappointmentService.selectExappointmentById(id);
        mmap.put("exappointment", exappointment);
        return prefix + "/edit";
    }

    /**
     * 修改保存展览预约
     */
    @RequiresPermissions("system:exappointment:edit")
    @Log(title = "展览预约", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(Exappointment exappointment)
    {
        return toAjax(exappointmentService.updateExappointment(exappointment));
    }

    /**
     * 删除展览预约
     */
    @RequiresPermissions("system:exappointment:remove")
    @Log(title = "展览预约", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(exappointmentService.deleteExappointmentByIds(ids));
    }
}
